<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<!--<meta name="viewport" content="width=device-width, initial-scale=1">-->
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>糖果计划</title>
		<script src="//cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
		<script src="//cdn.jsdelivr.net/clipboard.js/1.5.12/clipboard.min.js"></script>
		<script src="__CDN__/assets/js/template-web.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="__CDN__/assets/css/activity.css" />
	</head>

	<body>
		<div class="header">
			<div class="header-img"><img src="__CDN__/assets/img/active/title@2x.png" /></div>
			<div class="act-time">活动时间：2018-06-26 至 2018-06-30</div>
		</div>
		<div class="main1">
			<div class="main1-sec">
				<img src="__CDN__/assets/img/active/icon_wallet_01@2x.png" />
				<p>资产管理</p>
				<span>多重防盗</span>
				<span>轻松管理</span>
			</div>
			<div class="main1-sec">
				<img src="__CDN__/assets/img/active/icon_qr_02@2x.png" />
				<p>一键转账</p>
				<span>安全便捷</span>
				<span>实时可查</span>
			</div>
			<div class="main1-sec main1-sec3">
				<img src="__CDN__/assets/img/active/icon_hq_03@2x.png" />
				<p>关注行情</p>
				<span>行情有数</span>
				<span>从容投资</span>
			</div>
		</div>
		<div class="main2">
			<div class="main2-sec">
				<span class="main2-span1"> </span>
				<div class="main2-title">第一步：选择您要领取的钱包</div>
				<span class="main2-span2"> </span>
			</div>
			<form action="{:url('api/activity/getLottery')}" method="post" id="form">
				<input class="main2-put1" type="text" value="" placeholder="请输入钱包地址" />
				<input class="main2-put2" type="text" value="" placeholder="请输入邀请码" />
				<hr />
				<button class="main2-put3">领取cam</button>
				<div class="main2-def">默认邀请码</div>
			</form>
		</div>

		<div class="main22">
			<div class="main22-sec">
				<span class="main22-span1"> </span>
				<div class="main22-title">第一步：选择您要领取的钱包</div>
				<span class="main22-span2"> </span>
			</div>
			<div class="main22-sec2">
				<img src="__CDN__/assets/img/active/icon_Symbol_01@2x.png" />
				<p>
					<span>恭喜您获得<span class="number"></span>个CAM</span><br />
					<span>继续邀请好友获得更多CAM吧</span>
				</p>
				<img src="__CDN__/assets/img/active/icon_Symbol_02@2x.png" />
			</div>
		</div>

		<div class="main3">
			<div class="main3-sec">
				<span class="main3-span1 main3-span"></span>
				<div class="main3-title">第二步：邀好友&#x3000;领CAM</div>
				<span class="main3-span2 main3-span"> </span>
			</div>
			<div class="main3-sec2">
				<p>&#x3000;<img src="__CDN__/assets/img/active/icon_Symbol_01@2x.png" />每邀请一位好友下载并注册“币伯钱包”</p>
				<p>APP，即可额外获得1-5个cam<img src="__CDN__/assets/img/active/icon_Symbol_02@2x.png" /></p>
			</div>
			<div class="main3-sec3">
				<ul></ul>
			</div>
			<hr class="hr2" />
			<div class="main3-sec4">
				<div class="main3-sec4-d1">我的邀请码</div>
				<div class="main3-sec4-d2">
					<div>
						<span class="copyText" id="copyText"></span>
						<textarea id="input"></textarea>
						<img class="copy" src="__CDN__/assets/img/active/icon_copy@2x.png" />
					</div>
					<div class="share">分享</div>
				</div>
			</div>
			<hr class="hr3" />
			<div class="main3-sec5">
				<div class="main3-sec5-d1 main3-sec5-d">
					<img src="__CDN__/assets/img/active/icon_recom@2x.png" alt="" />
					<p>
						<span>推荐好友数量</span>
						<span class="peopel"> </span>
					</p>
				</div>
				<div class="main3-sec5-d2 main3-sec5-d">
					<img src="__CDN__/assets/img/active/icon_coin@2x.png" alt="" />
					<p>
						<span>奖励</span>
						<span class="num"> </span>
					</p>
				</div>
			</div>
		</div>

		<div class="main4">
			<div class="main4_sec">
				<dl class="main4_sec4">
					<dt>活动说明</dt>
					<dd>
						<p><span class="list"> </span><span class="list_text">用户可通过“币伯钱包“APP查看活动所获糖果数：“我的” - “活动” - “有你计划活动”</span></p>
						<p><span class="list"> </span><span class="list_text">活动所得糖果将在活动结束5个工作日内发放至用户指定钱包账户。</span></p>
						<p><span class="list"> </span><span class="list_text">同一设备登录即视为同一用户。</span></p>
						<p><span class="list"> </span><span class="list_text">以下行为在本活动中将视为违规，主办方有权取消用户参与活动资格，且用户活动所得糖果将不予发放：</span>
							<ul>
								<li>a. 以非法盈利为目的参与活动；</li>
								<li>b. 恶意使用多个账号参与活动；</li>
								<li>c. 通过机器人软件或其他自动方式参与活动；</li>
								<li>d. 其他非真实领取的作弊行为。</li>
							</ul>
						</p>
						<p><span class="list"> </span><span class="list_text">若活动期间出现不可抗因素或大面积恶意套利行为、通讯线路故障、计算机大规模瘫痪等原因导致活动难以继续开展，主办方有权修改、暂停或取消本活动。</span></p>
						<p><span class="list"> </span><span class="list_text">若因用户电子设备不支持或其他系统问题导致用户无法正常参与活动等情况，主办方不承担相关责任。</span></p>
						<p><span class="list"> </span><span class="list_text">活动最终解释权归“币伯钱包”研发中心所有。</span></p>
					</dd>
				</dl>
			</div>
		</div>

		<div class="main5">
			<div class="main5-sec"><span>恭喜您获得</span> <span class="main5-num"></span> <span>CAM</span></div>
			<hr />
			<div class="main5-sec2">糖果将在活动结束5个工作日内发送至您指定的钱包地址，请注意查收！</div>
			<div class="main5-close">&#10005;</div>
		</div>

		<div class="main6">
			<div class="main6-1" id="main6-1">
				<div class="main6-sec" id="main6-sec"><span>邀请码：</span><span class="invite"></span></div>
				<div class="main6-sec2" id="main6-sec2">我在“币伯钱包”邀你一起瓜分2,000,000CAM！时不可待，速来抢币！</div>
				<div class="main6-sec4" id="main6-sec4">请在浏览器中打开链接</div>
				<div class="main6-sec5" id="main6-sec5"></div>
			</div>
			<hr />
			<textarea id="input2"></textarea>
			<div class="main6-sec6">复制分享</div>
			<div class="main6-close">&#10005;</div>
		</div>

		<div class="main7">
			<div class="main7-sec"></div>
		</div>
		
		<div class="main8">复制成功！</div>
		
		<div class="main9"></div>

		<!--遮罩层-->
		<div id="screen"></div>
	</body>

</html>
<script type="text/javascript">
    var activityId = '';
    var userId = '';
    //适配移动端
    function resize() {
        var deviceWidth = document.documentElement.clientWidth;
        if(deviceWidth < 240) deviceWidth = 240;
        document.documentElement.style.cssText = 'font-size:' + (deviceWidth / 15) + 'px!important';
    }
    window.addEventListener('resize', resize);
    resize();
    
    //设置main9居中
    function autoCenter(){
    	var main9 = document.getElementsByClassName('main9')[0];
    	var width = main9.offsetWidth/2;
    	var winWidth = window.innerWidth/2;
    	var left = winWidth - width;
    	main9.style.left = left + "px";
    }
    autoCenter();
    
    //接口
    function apiForm(mesg){
           activityId = mesg.activity_id;
           userId = mesg.user_id;
           var mobile = mesg.mobile,
		       email = mesg.email,
               deviceType = mesg.device_type,
			   deviceToken = mesg.device_token,
		       url = "{:url('api/activity/getUserReceive')}";
        $.ajax({
        	type:'POST',
        	url:url,
        	data:{
               activity_id:activityId,
               user_id: userId,
               mobile: mobile,
               email: email,
               device_type: deviceType,
			   device_token:deviceToken
        	},
            dataType: 'json',
            success:function (resp) {
                var data = resp.data,
				    code = resp.code,
			        msg = resp.msg;
			    if ( code == 1 ) {
                   var status = data.status,
                       num = data.cam,
                       my_receive = data.myReceive,
                       rankList = data.rankList;
                   if ( status == 1 ) {
                       $('.number').text(num);
                       $('.main22').show();
                       $('.main2').hide();
                   }else {
                       $('.main2').show();
                       $('.main22').hide();
                   }
                   $('.copyText').text(my_receive.invitation_code);
                   $('.peopel').text(my_receive.recommend_num + '人');
                   $('.num').text(my_receive.invite_quantity + 'cam');
                   rank(rankList);
			   }else {
                   if ( data == 0 ) {
                       window.location.href = '../activity/ending';
				   }else {
                       $('.main9').text(msg);
                       $(".main9").show().delay(1500).fadeOut();
				   }
			   }
           },
           error:function () {
               alert('请求数据出错！');
           }
        });
    }
    //排名
	function rank(list) {
        if ( list == '' ) {
            $('.main3-sec2').hide();
            $('.hr2').hide();
		}else {
            $.each(list,function (index, value, arr) {
                var order = index + 1;
                var num = value.quantity + value.invite_quantity;
                if ( value.mobile != '' ) {
                    var val = value.mobile;
                    var reg = /^(\d{3})\d{3}(\d{5})$/;
                    val = val.replace(reg, "$1***$2");
				}else if ( value.email != '' ) {
                    var val = value.email;
                    var reg = /(.{3}).+(@)(.{3})/;
                    val = val.replace(reg, "$1***$2");
				}else {
                    var val = '138***88888'
				}
                var html = '<li>'+
                    '<span>NO.'+order+'</span>'+
                    '<span>'+val+'</span>'+
                    '<span>已领取'+num+'个cam</span>'+
                    '</li>';
                $('.main3-sec3 ul').append(html);
            });
		}
    }
    //抽奖
	$('.main2-put3').click(function () {
         var form = $('#form'),
	         address = $('.main2-put1').val(),
			 code = $('.main2-put2').val();
		 $.ajax({
			 type:'POST',
			 url:form.attr('action'),
             dataType: 'json',
			 data:{
                 activity_id: activityId,
                 user_id: userId,
                 address: address,
                 invitation_code: code
			 },
			success:function (resp) {
				//使得用户无法滚动
				document.documentElement.style.overflow = 'hidden';
				if ( resp.code != 0 ) {
                    var num = resp.data;
                    $('.main5-num').text(num);
                    $('.number').text(num);
                    $('#screen').fadeIn(200);
                    $('.main5').fadeIn(300);
				}else {
                    var msg = resp.msg;
                    $('.main9').text(msg);
                    $(".main9").show().delay(1500).fadeOut();
                    autoCenter();
				}
            },
			error:function () {
				console.log('请求数据出错！');
            }
        });
		return false;
    });
    //默认邀请码
    $('.main2-def').click(function(){
        $('.main2-put2').val("a76486");
    });
    //分享
    $('.share').click(function(){
        var url = "http://t.cn/Rrpn97J",
            invite = $('.copyText').text();
        $('.main6-sec5').text(url);
        $('.invite').text(invite);
        $('#screen').fadeIn(200);
        $('.main6').fadeIn(300);
    });
    // 点击关闭按钮弹出框要隐藏掉
    $('.main5-close').click(function() {
        $('.main5').fadeOut(300);
        $('#screen').fadeOut(200);
        $('.main2').hide();
        $('.main22').show();
        //使得用户可以滚动
        document.documentElement.style.overflow = 'auto';
    });
    // 点击关闭按钮弹出框要隐藏掉
    $('.main6-close').click(function() {
        $('.main6').fadeOut(300);
        $('#screen').fadeOut(200);
        //使得用户可以滚动
        document.documentElement.style.overflow = 'auto';
    });
	//复制
		var copy = document.getElementsByClassName('copy')[0];
		copy.addEventListener('click', function() {
			if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) { //区分iPhone设备  
				window.getSelection().removeAllRanges(); //这段代码必须放在前面否则无效  
				var Url2 = document.getElementById("copyText"); //要复制文字的节点  
				var range = document.createRange();
				// 选中需要复制的节点  
				range.selectNode(Url2);
				// 执行选中元素  
				window.getSelection().addRange(range);
				// 执行 copy 操作  
				var successful = document.execCommand('copy');

				// 移除选中的元素  
				window.getSelection().removeAllRanges();
				$(".main8").show().delay(1500).fadeOut();
			} else {
				var Urltext = document.getElementById("copyText").innerText;
				var Url2 = document.getElementById("input"); //要复制文字的节点
				Url2.innerText = Urltext;
				Url2.select(); // 选择对象
				document.execCommand("Copy"); // 执行浏览器复制命令
				console.log("复制成功");
				$(".main8").show().delay(1500).fadeOut();
			}
		});
		//复制
		var copy2 = document.getElementsByClassName('main6-sec6')[0];
		copy2.addEventListener('click',function(){
			if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) { //区分iPhone设备  
			window.getSelection().removeAllRanges(); //这段代码必须放在前面否则无效  
			var Url2 = document.getElementById("main6-1"); //要复制文字的节点  
			var range = document.createRange();
			// 选中需要复制的节点  
			range.selectNode(Url2);
			// 执行选中元素  
			window.getSelection().addRange(range);
			// 执行 copy 操作  
			var successful = document.execCommand('copy');

			// 移除选中的元素  
			window.getSelection().removeAllRanges();
			console.log("复制成功")
			} else {
			
			var Urltext = document.getElementById("main6-1").innerText;
			var Url2 = document.getElementById("input2"); //要复制文字的节点
			Url2.innerText = Urltext;
			Url2.select();  // 选择对象
			document.execCommand("Copy"); // 执行浏览器复制命令
			console.log("复制成功");
            //弹窗提示
			$(".main8").show().delay(1500).fadeOut();
		}
	});
</script>

